//
//  GHNewGoodsTableViewCell.m
//  GodHorses
//
//  Created by Mac on 2017/11/17.
//  Copyright © 2017年 stoneobs@icloud.com. All rights reserved.
//

#import "GHNewGoodsTableViewCell.h"
@interface GHNewGoodsTableViewCell()
@property(nonatomic, strong) UIImageView                     *iconImageView;
@property(nonatomic, strong) UIImageView                     *smallIconImageView;
@property(nonatomic, strong) STLabel                            *titleLable;
@property(nonatomic, strong) STLabel                            *descLable;
@property(nonatomic, strong) STLabel                            *moneyLable;
@end
@implementation GHNewGoodsTableViewCell
+ (CGFloat)cellHeight{
    return 210;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self configSubView];
    }
    return self;
}
#pragma mark --subView
- (void)configSubView{
    UIView * whiteView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, [GHNewGoodsTableViewCell cellHeight] - 10)];
    whiteView.backgroundColor = [UIColor whiteColor];
    [self addSubview:whiteView];
    
    self.iconImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 170, whiteView.st_height)];
    self.iconImageView.image = [UIImage imageNamed:@"1"];
    [whiteView addSubview:self.iconImageView];
    
    UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 27, 42)];
    imageView.image = [UIImage imageNamed:@"xinpinshangshi"];
    imageView.st_right = UIScreenWidth  - 10;
    [whiteView addSubview:imageView];
    
    self.smallIconImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 60, 60)];
    self.smallIconImageView.image = [UIImage imageNamed:@"xiao_cp03"];
    self.smallIconImageView.centerX = self.iconImageView.st_right;
    self.smallIconImageView.st_bottom = whiteView.st_height - 20;
    [whiteView addSubview:self.smallIconImageView];
    
    STLabel * titleLable = [[STLabel alloc] initWithFrame:CGRectMake(self.iconImageView.st_right + 20, 55, UIScreenWidth - 30 - self.iconImageView.st_right, 16)
                                                     text:@"神马全高溶氧水黄金版"
                                                textColor:UIColorFromRGBA(0x2c2c2c)
                                                     font:15
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentLeft];
    self.titleLable = titleLable;
    [whiteView addSubview:self.titleLable];
    
    STLabel * orginLable = [[STLabel alloc] initWithFrame:CGRectMake(self.titleLable.st_left, self.titleLable.st_bottom + 10, 60, 15)
                                                     text:@"原厂出品"
                                                textColor:[UIColor whiteColor]
                                                     font:11
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentCenter];
    orginLable.backgroundColor = UIColorFromRGBA(0x192138);
    [whiteView addSubview:orginLable];
    
    self.descLable = [[STLabel alloc] initWithFrame:CGRectMake(orginLable.st_right, orginLable.st_top, self.titleLable.st_width - orginLable.st_width, orginLable.st_height)
                                                     text:@" 钻石款高溶氧水25件"
                                                textColor:UIColorFromRGBA(0x323232)
                                                     font:11
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentLeft];
    [self.descLable st_setBorderWith:1 borderColor:UIColorFromRGBA(0x192138) cornerRadius:0];
    [whiteView addSubview:self.descLable];
    
    self.moneyLable = [[STLabel alloc] initWithFrame:CGRectMake(self.titleLable.st_left, orginLable.st_bottom + 20, self.titleLable.st_width, 20)
                                                     text:@"新品价：34400元"
                                                textColor:GH_firstTextColor
                                                     font:15
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentRight];

    [whiteView addSubview:self.moneyLable];
    
    STButton * buyButton = [[STButton alloc] initWithFrame:CGRectMake(0, 0, 85, 25)
                                                     title:@"立即抢购>>"
                                                titleColor:[UIColor whiteColor]
                                                 titleFont:13
                                              cornerRadius:5
                                           backgroundColor:UIColorFromRGBA(0x192138)
                                           backgroundImage:nil
                                                     image:nil];
    buyButton.st_right = self.titleLable.st_right;
    buyButton.bottom = whiteView.st_height - 10;
    buyButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    buyButton.userInteractionEnabled = NO;
    [whiteView addSubview:buyButton];
    
    
}
- (void)setModel:(GHGoodModel *)model{
    _model = model;
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:model.g_img] placeholderImage:nil];
    
    self.titleLable.text = [NSString stringWithFormat:@"%@%@",model.g_name,model.c_name];
    
    self.descLable.text = [NSString stringWithFormat:@"  %@",model.g_name];
    
    self.moneyLable.text = [NSString stringWithFormat:@"新品价:%@元",model.i_price];
    self.moneyLable.attributedText = [self.moneyLable.text
                                      st_convertAttributeStringWithKeyWord:[NSString stringWithFormat:@"%@元",model.i_price]
                                      attributes:@{NSForegroundColorAttributeName:GH_redColor}];
}
@end
